<?php
function _compress($buffer) {
	$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
	$buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
	return stripcslashes($buffer);
}

$outName = 'meishi_portal.css';
$p_folder = 'D://MyWorkFiles/qq美食/model_03/styles/';
$p_folder = iconv("UTF-8","gb2312",$p_folder);
$p_output = $p_folder .$outName;

$s_list = array(
	"meishi_portal_source.css"
);

$result = '';

foreach ($s_list as $path) {
	$filepath = $p_folder.$path;
	$content = file_get_contents($filepath);
	$result .= "\r\n\r\n".$content;
}

$result = _compress($result);

$tmp = fopen('tmp.css', "w");
fwrite($tmp, $result);
fclose($tmp);
system("del tmp.css");

$out = fopen($p_output, "w");
fwrite(
	$out, 
	"/* meishi_protal version: "
	.date_format( new DateTime(), 'ymd-i' )
	."*/\r\n\r\n"
	.$result
);
fclose($out);

echo 'finished at '.time();

?>